//
//  ForgetPasswordViewController.m
//  WuJieLive
//
//  Created by 张瀚坤 on 2017/10/25.
//  Copyright © 2017年 zhk. All rights reserved.
//

#import "ForgetPasswordViewController.h"
#import "NewPasswordViewController.h"

@interface ForgetPasswordViewController ()
@property (weak, nonatomic) IBOutlet UITextField *phoneText;
@property (weak, nonatomic) IBOutlet UIButton *nextBtn;

@end

@implementation ForgetPasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)setNavi
{
    self.title = @"找回密码";
    
}

-(void)setUI
{
    self.view.backgroundColor =  Color(245, 245, 245);
    [self.phoneText addTarget:self action:@selector(changeLength:) forControlEvents:(UIControlEventEditingChanged)];
}

- (void)changeLength:(UITextField *)textField
{
    if (self.phoneText.text.length == 11) {
        self.nextBtn.userInteractionEnabled = YES;
        [self.nextBtn setBackgroundColor:MainColor];
    }else
    {
        [self.nextBtn setBackgroundColor:MainBtnColor];
        self.nextBtn.userInteractionEnabled = NO;
    }
}
// 17396255193
- (IBAction)nextAction:(id)sender {
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    NSDictionary * dict = @{@"phone_mob":self.phoneText.text};
    [HTTPTool POSTForm:[NSString stringWithFormat:@"%@deposit-account/find-login-password",BaseUrl] para:dict success:^(BOOL isSuccess, id responseObject) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        if (isSuccess) {
            NewPasswordViewController * vc = [[NewPasswordViewController alloc]init];
            self.redisKey = [[responseObject objectForKey:@"data"] objectForKey:@"phone_redis_key"];
            [self.navigationController pushViewController:vc animated:YES];
        }
    } failure:^(NSError *error) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
